/**
 * @FileName FlyWeightFactory.java
 * @Package com.designMode.flyweight
 * -------------------------------------
 * @function Please write description of function
 * @Date 2016-1-19 下午3:43:41
 * -------------------------------------
 * Copyright (c) 2016,顾博君 All Rights Reserved.
 */
package com.designMode.flyweight;

import java.util.HashMap;

/**
 * @ClassName FlyWeightFactory
 * @author 顾博君
 * @Date 2016-1-19 下午3:43:41
 * @Function 享元工厂
 */
public class FlyWeightFactory {
	private static HashMap<String, FlyWeight> pool = new HashMap<>();

	public static FlyWeight getFlyWeight(String extrinsic) {
		FlyWeight flyWeight;
		if (pool.containsKey(extrinsic)) {
			flyWeight = pool.get(extrinsic);
		} else {
			flyWeight = new ConcreteFlyWeight(extrinsic);
			pool.put(extrinsic, flyWeight);
		}
		return flyWeight;
	}
}
